package br.inf.solutions.apresentacoes.ssp.model.bulletin.items;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import br.com.vexillum.model.annotations.SearchField;
import br.com.vexillum.model.annotations.Validate;
import br.com.vexillum.model.annotations.ValidatorClass;
import br.com.vexillum.util.SpringFactory;
import br.inf.solutions.apresentacoes.ssp.control.TransferReserveController;
import br.inf.solutions.apresentacoes.ssp.model.Person;
import br.inf.solutions.apresentacoes.ssp.model.ReasonTransferReserve;
import br.inf.solutions.apresentacoes.ssp.model.bulletin.BulletinItem;
import br.inf.solutions.apresentacoes.ssp.model.bulletin.BulletinTopics;
import br.inf.solutions.apresentacoes.ssp.model.enums.SalaryReserve;
import br.inf.solutions.apresentacoes.ssp.model.hierarchy.HierarchyStructEntity;
import br.inf.solutions.apresentacoes.ssp.model.interfaces.IExistsPerson;

@SuppressWarnings("serial")
@ValidatorClass(validatorClass = "br.inf.solutions.apresentacoes.ssp.control.validator.TransferReserveValidator")
@Entity
@Table(name = "trasnferreserve")
public class TransferReserve extends BulletinItem implements IExistsPerson {

	public TransferReserve() {
		super(new BulletinTopics(6l, "TransferReserve", "/paginas/transferenciareserva/retificacao.zul"));
		this.reason = new ReasonTransferReserve();
	}

	@Validate(notNull = true)
	@SearchField
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "person_id",  nullable=false, insertable = true, updatable = true, unique = false)
	private Person person;

	@Validate(notNull = true)
	@Column(name = "salaryreserve", unique = false, updatable = true)
	@Enumerated(EnumType.STRING)
	private SalaryReserve salaryReserve;

	@Validate(notNull = true)
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "reason", nullable=false, insertable = true, updatable = false, unique = false)
	private ReasonTransferReserve reason;

	@Validate(notNull = true)
	@Column(name = "datereserve", insertable = true, updatable = true, unique = false)
	private Date dateReserve;

	@SearchField
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "unitOld", insertable = true, updatable = false, unique = false)
	private HierarchyStructEntity unitOld;

	public Person getPerson() {
		return person;
	}

	public void setPerson(Person person) {
		this.person = person;
	}

	public SalaryReserve getSalaryReserve() {
		return salaryReserve;
	}

	public void setSalaryReserve(SalaryReserve salaryReserve) {
		this.salaryReserve = salaryReserve;
	}

	public ReasonTransferReserve getReason() {
		return reason;
	}

	public void setReason(ReasonTransferReserve reason) {
		this.reason = reason;
	}

	public Date getDateReserve() {
		return dateReserve;
	}

	public void setDateReserve(Date dateReserve) {
		this.dateReserve = dateReserve;
	}

	public HierarchyStructEntity getUnitOld() {
		return unitOld;
	}

	public void setUnitOld(HierarchyStructEntity unitOld) {
		this.unitOld = unitOld;
	}

	@Override
	public TransferReserveController getControl() {
		return SpringFactory.getController("transferReserveController", TransferReserveController.class, null);
	}
}
